<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:include page="../include/header.jsp"></jsp:include>
<script type="text/javascript">
   $(function(){
	   $("#jqGrid").jqGridUtils({
			"url":"jqGrid/queryPage/role_mgr_list.do",
			"colModel":[
			            {label: "ID",name: "id", hidden:true, key:true},
			            {label: "名称" ,name: "name",width:200,formatter:function(cellvalue, options, rowObject) {
			            	return "<a href='#' onclick=\"return viewInfo('"+rowObject[0]+"')\">"+cellvalue+"</a>";
			            }},
			            {label: "状态" ,name: "state",width:100},
			            {label: "描述" ,name: "descr",width:200},
			            {label: "创建时间" ,name: "createTime"}],
			//caption: "角色列表",
			tableTitleIcon: "fa-users",
			"gridview":true,
			"rowNum":${pageSize},
			tableStyle:"table table-bordered",
			"scrollrows":true,
			multiselect: true,
			"datatype":"json",
			"pager":"#jqGridPager"
		});
	   $("#jqGrid").jqGrid('navGrid','#jqGridPager',
			   {add:true,addfunc: function(){
				   //获取选中数据
				   var id=$("#jqGrid").jqGrid('getGridParam','selrow');
				   id = utils.handleNull(id);
				   if(utils.isEmpty(id)) {
					   id = "0";
				   }
				   //提出弹出窗口
				   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('添加角色', 'role/add.do?jqGridId=jqGrid&id='+id, 'fa fa-plus', null, null, function(){
					   window.parent.MixElementListener.initEvent();
				   });
			   }, edit:true,editfunc:function(){
				 //获取选中数据
				   var id = $("#jqGrid").jqGrid('getGridParam','selrow');
				   id = utils.handleNull(id);
				   if(utils.isEmpty(id)) {
					   window.parent.BootstrapDialogUtil.warningAlert(null,"请选择一条要编辑的数据！");
				   } else {
					   window.parent.BootstrapDialogUtil.loadUriSubmitDialog('修改角色', 'role/edit.do?id='+id+'&jqGridId=jqGrid', 'fa fa-pencil-square-o', null, null, function(){
						   window.parent.MixElementListener.initEvent();
					   });
				   }
			   }, del:true,delfunc:function(){
				 //获取选中数据
				   var ids = $("#jqGrid").jqGrid('getGridParam','selarrrow');
				   if(ids.length == 0) {
					   window.parent.BootstrapDialogUtil.warningAlert(null,"请选择要删除的数据！");
				   } else {
					   window.parent.BootstrapDialogUtil.delDialog(null,"选中的角色",'role/delete.do',ids.join(','),function(){
						 refreshJqGrid();
					 });
				  }
			   }, view:false, search:false},{id:'edit'},{id:'add'});
   });

   //刷新列表
   function refreshJqGrid() {
	   $("#jqGrid").trigger("reloadGrid");
   }
   
   /**
    * 查看信息
    */
   function viewInfo(id) {
	   window.parent.BootstrapDialogUtil.loadUriDialog("查看角色",'show/page/web_role_show.do?roleId='+id, 'fa fa-wpforms', null, null, false, function(){
		   window.parent.MixElementListener.initEvent();
	   });
	   return false;
   }
</script>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
<jsp:include page="../include/footer.jsp"></jsp:include>
